#include <iostream>

class Printable
{
public:
    virtual std::string GetClassName() = 0;  //纯虚函数
};

class Entity : public Printable{
public:
    virtual std::string GetName()  { return "Entity"; };
    std::string GetClassName() override { return "Entity classname"; }
};

class Player : public Entity{
public:

    Player(const std::string name) : m_Name(name)
    {

    }

    //如果子类没有重写基类的虚函数那么就调用基类的
    std::string GetName() override
    {
        return m_Name;
    }
    
    std::string GetClassName() override { return "Player classname"; } 

private:
    std::string m_Name;
};


void PrintName(Entity* entity)
{
    std::cout << entity->GetName() << std::endl;
}

void Print(Printable* printable)
{
    std::cout << printable->GetClassName() << std::endl;
}


int main()
{
    Entity* entity = new Entity();
    Player* player = new Player("caoxiansheng");
    
    PrintName(entity);
    PrintName(player);
    

    Print(entity);
    Print(player);

    return 0;
}